<template>
  <div class="consensus-activity-app">
    <div>
      <img :src="user.avatar_image" />
    </div>
    <div class="level">
      <span>星级</span>
      <span>{{user.grade_name}}</span>
    </div>
    <div class="content">
      <div class="between mb-48">
        <span>团队数据</span><span @click="link">查看详情<i class="iconfont icon-member_right"></i></span>
      </div>
      <div class="flex-wrap">
        <div class="column" v-for="item in team_data" :key="item.name">
          <span>{{item.name}}</span>
          <span>{{item.value}}</span>
        </div>
      </div>
    </div>
    <div class="exit" @click="exit">退出登录</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      team_data: [],
      user: {},
    };
  },
  activated() {
    this.getData();
  },
  methods: {
    exit(){
      $http.get("member.logout.index").then(
        response => {
          if (response.result == 1) {
            window.localStorage.setItem("isWxLogin", -1);
            localStorage.setItem("token", "");
            localStorage.setItem("loginUid", "");
            window.firstLogin = 0;
            this.$store.commit("savemodel", {});
            clearLoginData(); // 方法在index.html
            this.$dialog
              .alert({ message: response.msg })
              .then(() => {
                this.$router.push(this.fun.getUrl("login"));
              })
              .catch(() => {});
          }
        }
      );
    },
    getData() {
      $http.get("plugin.wise-yuan-trade.frontend.app-page.index", "", "").then(({ result, msg, data }) => {
        if (result) {
          console.log(data, "data==");
          this.team_data = data.team_data;
          this.user = data.user;
        } else {
          this.$toast(msg);
        }
      })
    },
    link() {
      this.$router.push(this.fun.getUrl('consensus_activity_team'))
    },
  }
};
</script>

<style scoped lang="scss">
.consensus-activity-app {
  padding: 0.6563rem 0.75rem;

  .exit {
    background: #ef5452;
    color: #fff;
    border-radius: 0.625rem;
    height: 3.4375rem;
    line-height: 3.4375rem;
    margin-top: 0.6875rem;
  }

  img {
    width: 100%;
    margin: 0;
  }

  .mb-48 {
    margin-bottom: 1.5rem;
  }

  .flex-wrap {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    grid-column-gap: 15px;
    grid-row-gap: 15px;
  }

  .column {
    display: flex;
    flex-direction: column;
  }

  .between {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .content {
    margin-top: 0.625rem;
    padding: 0.9375rem 0.7188rem;
    background: #fff;
    border-radius: 0.625rem;
  }

  .level {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 0.75rem;
    background: #fff;
    border-radius: 0.625rem;
    margin-top: 0.7188rem;
  }
}
</style>
